(library (model handler-config)
  (export
   ;; constructors
   construct-handler-config
   make-handler-config
   ;; predicate
   handler-config?
   ;; getters
   handler-config-handler
   handler-config-handles-children?)
  (import
    (except (rnrs base) let-values error)
    (only (guile)
          lambda* λ)
    ;; exception handling
    ;; (ice-9 exceptions)
    (prefix (srfi srfi-1) srfi-1:)
    ;; for functional structs (not part of srfi-9 directly)
    (srfi srfi-9 gnu)))


(define-immutable-record-type <handler-config>
  ;; define constructor
  (construct-handler-config handler handles-children)
  ;; define predicate
  handler-config?
  ;; define accessors and functional setters
  (handler handler-config-handler)
  ;; A handler handling children means, that the handler handles any request for
  ;; a route, which starts with some route parts, instead of only requests,
  ;; which exactly match the specified route parts. One example for such a
  ;; handlers is the handler for static assets.
  (handles-children handler-config-handles-children?))


(define make-handler-config
  (lambda* (handler #:key (handles-children #f))
    (construct-handler-config handler handles-children)))
